package 力扣日常刷题.木22一月.第13天0121;

/**
 * @author 帅小伙
 * @date 2022/1/21
 * @description
 */
public class Demo38动态规划简单第N个泰波那契数 {


    public int tribonacci(int n) {
        int a = 0,b = 1,c = 1;
        if(n == 0) return 0;
        if(n <= 2)  return 1;

        n-=2;

        for (int i = 0; i < n; i++) {
            int t = a;
            a = b;
            b = c;
            c = a+b+t;
        }
        return c;
    }

}
